package com.votesys.service;

import java.util.List;

import com.votesys.model.Votecontent;
import com.votesys.model.VotecontentDAO;
import com.votesys.model.Votetopic;

public class ContentServiceImpl implements IContentService{

	private VotecontentDAO VotecontentDAO;
	
	public VotecontentDAO getVotecontentDAO() {
		return VotecontentDAO;
	}

	public void setVotecontentDAO(VotecontentDAO votecontentDAO) {
		VotecontentDAO = votecontentDAO;
	}

	@Override
	public Votecontent getContent(int contentID) {
		// TODO Auto-generated method stub
		return VotecontentDAO.findById(contentID);
	}
	
	@Override
	public List getContentList(int TopicID){
		return VotecontentDAO.findByTopicId(TopicID);
	}
	
	@Override
	public void addContent(int topicID, String contentName,
			String contentAbstract, String contentDetail, byte[] pic) {
		// TODO Auto-generated method stub
		Votecontent tempVoteContent = new Votecontent();
		tempVoteContent.setTopicId(topicID);
		tempVoteContent.setContentName(contentName);
		tempVoteContent.setContentAbstract(contentAbstract);
		tempVoteContent.setContentDetail(contentDetail);
		tempVoteContent.setPic(pic);
		tempVoteContent.setContentCount(0);
		VotecontentDAO.save(tempVoteContent);
		
	}

	@Override
	public void updateContent(Votecontent votecontent) {
		// TODO Auto-generated method stub
		VotecontentDAO.merge(votecontent);
		
	}

	@Override
	public void deleteContent(Votecontent votecontent) {
		// TODO Auto-generated method stub
		
	}

}
